/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_WS_FLV_PLAYER_H
#define MK_WS_FLV_PLAYER_H
#include "MkHttp/MkHttpClient.h"
#include "MkMedia/MkMediaSource.h"
#include "MkFlv/MkFlvDemuxer.h"

class MkApi CMkWsFlvPlayer : public CMkHttpClient, public CMkMediaSource
{
public:
    CMkWsFlvPlayer(CMkEvent *pEvent, CMkTimer* pTimer, const MkEventRemovedCallback& RemovedCb);
    ~CMkWsFlvPlayer();

    Uint32 StartMediaSource(const MkString& Url, const MkSourceResultCallback& ResultCb, const MkEsPacketCallback& EsCb = nullptr);
    Uint32 StopMediaSource() override;
protected:
private:
    Uint32 OnFlvData(const Uint8* pBuf, Uint32 nLen);
private:
    Uint8*                      m_pBuf;
    Uint32                      m_nMaxLen;
    Uint32                      m_nOffset;
    CMkFlvDemuxer               m_FlvDemuxer;
};


#endif